package cn.mandifal.portal.controller;

import java.util.ArrayList;
import java.util.List;

import cn.mandifal.advertising.service.AdvertisingService;
import cn.mandifal.pojo.DpContent;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.dubbo.config.annotation.Reference;

@RestController
@RequestMapping("/advertisingController")
public class AdvertisingController {

	@Reference
	private AdvertisingService advertisingService;

	/**
	 * 通过分类查找广告
	 * @param categoryId 广告分类 id
	 * @return 返回广告 bean 列表
	 */
	@RequestMapping("/findByCategoryId")
	public List<DpContent> findByCategoryId(Long categoryId) {
		return advertisingService.findByCategoryId(categoryId);
	}
	/**
	 * 通过分类查找广告
	 * @param categoryIds 广告分类 id
	 * @return 返回广告 bean 列表
	 */
	@RequestMapping("/findLikeByCategoryId")
	public List<List<DpContent>> findLikeByCategoryId(Long[] categoryIds) {
		List<List<DpContent>> list=new ArrayList();
		for (Long categoryId:categoryIds) {
			List<DpContent> contentList = advertisingService.findByCategoryId(categoryId);
			list.add(contentList);
		}
		return list;
	}

}
